package com.credithc.signature.core.configure.datasource;

import org.apache.tomcat.jdbc.pool.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @desc: 配置JDBC模板<br />
 * @author: Jingbo Hu<br/>
 * @time：2020年09⽉14⽇<br/>
 * @version：v1.0.0<br>
 */
@Configuration
public class JdbcTemplateConfig {

    @Autowired
    DataSourceObtain dataSourceObtain;

    @Bean
    JdbcTemplate masterJdbcTemplate() {
        DataSource masterDataSource = dataSourceObtain.getMasterDataSource();
        return new JdbcTemplate(masterDataSource);
    }

    @Bean
    JdbcTemplate salveJdbcTemplate() {
        DataSource slaveDataSource = dataSourceObtain.getSlaveDataSource();
        return new JdbcTemplate(slaveDataSource);
    }
}
